let Template = {
  //处理资讯
  dealInfo: function (item) {
    //跳转到详情的参数
    let jsonStr = JSON.stringify({
      infoId: item.infoId,
      infoType: item.infoType
    })

    let isRead = localStorage.getItem('infoReadData_' + item.infoId)

    let htmlStr = '      <div class="flex-column info-list-box">\n' +
      '                <div class="flex-row justify-content-between info-list-item" onclick=\'goDetail(' + jsonStr + ', this)\'>\n' +
      '                    <div class="flex-column justify-content-between info-list-content flex-1">\n' +
      '                        <div class="info-list-title ff500 fspx15 line2 ' + (isRead === '1' ? 'info-list-read' : '') + '">' + item.mainTitle + '</div>\n' +
      '                        <div class="info-list-time fspx12 mt10">' + DateUtils.int2TimeDesc(item.issuerDttm) + '</div>\n' +
      '                    </div>\n'

    if (Utils.notEmpty(item.coverImgUrl)) {
      htmlStr += ' <div class="info-list-cover ml20">' +
        '                        <img src="' + item.coverImgUrl + '" alt="">\n' +
        '                    </div>\n'
    }


    htmlStr += '</div>'

    //处理关键词
    if (item.keyWords) {
      htmlStr += Template.dealWord(item)
    }

    htmlStr += '             </div>\n'


    return htmlStr
  },
  //处理大图资讯
  dealBigImgInfo: function (item) {

    let jsonStr = JSON.stringify({
      infoId: item.infoId,
      infoType: item.infoType
    })

    let htmlStr =
      '         <div class="flex-column info-list-bigbox" onclick=\'goDetail(' + jsonStr + ')\'>\n' +
      '            <div class="flex-column info-list-bigitem">\n' +
      '                <div class="info-list-title ff500 fspx15 line2">' + item.mainTitle + '</div>\n' +
      '                <img src="' + item.coverImgUrl + '" alt="">\n' +
      '            </div>\n' +
      '            <div class="flex-row justify-content-between align-items-center">\n'
    //处理关键词
    if (item.keyWords) {
      htmlStr += Template.dealWord(item)
    }

    htmlStr += '                <div class="flex-row justify-content-end info-list-bigtime fspx11">' + DateUtils.int2TimeDesc(item.issuerDttm) + '</div>\n' +
      '            </div>' +
      '         </div>'
    return htmlStr

  },

  dealWord: function (item) {
    // 1 产业链详情  3 债券   2、6 股票   5 数据  4 实体
    // 按照产业链、数据、股票、债券顺序依次显示，每次每个关键词分类显示一个关键词，以此类推循环显示，一直填满整行
    //  获取原始的keyWords
    let list = []
    if (item.keyWords) {
      list = JSON.parse(item.keyWords)
    }
    // 处理后端返回过来的type-url字符串转换为对象格式
    list.forEach(function (item, index) {
      let temList = []
      let temObj = {}
      // 去掉type-url末尾的分号
      let typeUrlLength = item['type-url'].length
      if (item['type-url'][typeUrlLength - 1] === ';') {
        item['type-url'] = item['type-url'].substring(0, typeUrlLength - 1)
      }

      temList = item['type-url'].split(';')
      temList.forEach(function (item, index) {
        let temItemList = item.split(':')
        temObj[temItemList[0]] = temItemList[1]
      })
      item['type-url'] = temObj
    })
    //  再次循环遍历list按产业链、数据、股票、债券、公司实体的先后顺序去排列；
    let tempArr = []
    //  分别设置布尔变量，来控制每种类型只显示一次；
    let obj = {}
    //
    list.forEach(function (item, index) {
      obj = {}
      // 产业链
      if (item['type-url']['1']) {
        obj = JSON.parse(JSON.stringify(item))
        if (obj['type-url'] !== '') {
          obj['type-url']['5'] = undefined
        }
        obj.index = 1
        tempArr.push(JSON.parse(JSON.stringify(obj)))
      } else if (item['type-url']['5']) {
        // 数据
        obj = JSON.parse(JSON.stringify(item))
        if (obj['type-url'] !== '') {
          obj['type-url']['1'] = undefined
          obj['type-url']['2'] = undefined
        }
        obj.index = 2
        tempArr.push(JSON.parse(JSON.stringify(obj)))
      } else if (item['type-url']['2']) {
        // 股票
        obj = JSON.parse(JSON.stringify(item))
        obj.index = 3
        tempArr.push(JSON.parse(JSON.stringify(obj)))
      } else if (item['type-url']['6']) {
        // 股票
        obj = JSON.parse(JSON.stringify(item))
        obj.index = 3
        tempArr.push(JSON.parse(JSON.stringify(obj)))
      } else if (item['type-url']['3']) {
        // 债券
        obj = JSON.parse(JSON.stringify(item))
        obj.index = 4
        tempArr.push(JSON.parse(JSON.stringify(obj)))
      }
      //if (is4First && item['type-url']['4']) {
      //  obj = JSON.parse(JSON.stringify(item))
      //  obj.index = 5
      //  tempArr.push(JSON.parse(JSON.stringify(obj)))
      //  is4First = false
      //}
    })
    //// 给temparr排序
    tempArr.sort(function (a, b) {
      return a.index - b.index
    })
    if (tempArr.length > 0) {
      let tempArrList = Utils.groupArr(tempArr, 'index')
      tempArr = []
      if (tempArrList.length > 0) {
        if (tempArrList.length === 1) {
          tempArr = tempArr.concat(tempArrList[0].list)
        } else {
          let max = tempArrList[0].list.length
          let index = 0
          for (let i = 0; i < tempArrList.length; i++) {
            if (max < tempArrList[i].list.length) {
              max = tempArrList[i].list.length
              index = i
            }
          }
          for (let i = 0; i < tempArrList[index].list.length; i++) {
            for (let j = 0; j < tempArrList.length; j++) {
              if (tempArrList[j].list.length > i) {
                tempArr.push(tempArrList[j].list[i])
              }
            }
          }
        }
      }
    } else {
      tempArr = []
    }
    let htmlStr = ''
    if (tempArr && tempArr.length > 0) {
      htmlStr += '                <div class="info-word-wrap">\n'
      // 循环遍历tempArr,生成对应的标签字符串
      let hasType1 = true, hasType2 = true, hasType3 = true, hasType4 = true, hasType5 = true
      tempArr.forEach(function (obj, index) {
        // if (index < 5) {
        $.each(obj['type-url'], function (key, value) {
          let childStr = '', exchange, stockCode
          if (hasType1 && obj['type-url']['1']) {
            childStr += ' <span class="iconfont iconchanyelian-01 fs12"></span>\n'
            childStr += ' <div class="info-word-word fs11">' + obj.key + '</div>\n'
            // hasType1 = false
          } else if (hasType5 && obj['type-url']['5']) {
            childStr += ' <span class="iconfont icon12 fs12"></span>\n'
            childStr += ' <div class="info-word-word fs11">' + obj.key + '</div>\n'
            //  hasType5 = false
          } else if (hasType3 && obj['type-url']['3']) {
            childStr += ' <div class="info-word-word fs11">' + obj.key + '</div>\n'
            //  hasType3 = false
            //} else if (hasType4 && obj['type-url']['4']) {
            //  childStr += ' <div class="info-word-word fs11">' + obj.key + '</div>\n'
            //  hasType4 = false
          } else if (hasType2 && (obj['type-url']['2'] || obj['type-url']['6'])) { //  股票涨跌幅
            childStr += ' <div class="info-word-word fs11">' + obj.key + '</div>\n'
            let arr = (obj['type-url']['2'] || obj['type-url']['6']).split('.')
            exchange = arr[0] ? arr[0].replace('*', '') : arr[0]
            stockCode = arr[1]
            if (obj['type-url']['6']) {
              let tempExchange = exchange
              exchange = stockCode
              stockCode = tempExchange
            }
            childStr += ' <div class="info-word-increase fs11 _' + (obj['type-url']['2'] ? arr[1] : arr[0]) + ' "></div>\n'
            pm.stockList.push(obj)
            //  hasType2 = false
          }

          if (childStr) {
            let jsonStr = JSON.stringify({
              type: key,
              word: obj.key,
              exchange: exchange,
              stockCode: stockCode
            })

            htmlStr += '   <div class="flex-row align-items-center justify-content-center info-word-item ff400" ' +
              '  onclick=\'goWordDetail(' + jsonStr + ')\'>\n'
            htmlStr += childStr
            htmlStr += '                    </div>\n'
          }
        })
        // }
      })

      htmlStr += '                    </div>\n'
    }

    return htmlStr
  },
  // 股票涨跌幅
  stockRise: function () {
    if (pm.stockList.length > 0) {
      let listContract = {
        listContract: [
          {
            //exchangeNo: 'SH',
            //commodityNo: '000001' ,
            //commodityType: 'S',
            //contractNo: '9999'
          }
        ]
      }
      listContract.listContract = []
      pm.stockList.forEach(function (item) {
        let it = (item['type-url']['2'] || item['type-url']['6']).split('.')
        let obj = {}
        obj.exchangeNo = item['type-url']['2'] ? it[0] : it[1]
        obj.commodityNo = item['type-url']['2'] ? it[1] : it[0]
        obj.commodityType = it[2]
        obj.contractNo = '9999'
        listContract.listContract.push(obj)
      })
      const buf = protoBuf.encodeToBase64('GetSnapshotRequest', listContract)
      Server.infoDetail.getSnapshot({
        request: buf
      }).then(function (data) {
        let result = protoBuf.decodeFromBase64('GetSnapshotResponse', data.data)
        result.listSnapshot.forEach(function (item) {
          if (item.changeRate) {
            if (item.changeRate > 0) {
              $('._' + item.commodityNo).html('<span style="color:#EC3E33">+' + (item.changeRate * 100).toFixed(2) + '%</span>')
            } else {
              $('._' + item.commodityNo).html('<span style="color:#00AE1F">' + (item.changeRate * 100).toFixed(2) + '%</span>')
            }
          } else {
            $('._' + item.commodityNo).html('<span style="color:#222222">停牌</span>')
          }
        })

      })
    }
  },

  /**
   * @param callback 翻页回调函数
   * @param program 滚动中需要单独实现的业务逻辑函数
   */
  pageScroll: function (callback, program) {
    //需要特殊处理的滚动区域，需要放在scroller元素区域内
    $(window).on('scroll', function () {
      if (pm.isScroll) {
        let scrollTop = $(this).scrollTop()
        let scrollHeight = $(document).height()
        let windowHeight = $(this).height()
        if (pm.isScroll && scrollTop + windowHeight >= scrollHeight - 100) {

          $('.more').html('加载中…')

          //防止二次加载
          pm.isScroll = false
          pm.pageNum++

          if (callback) {
            callback()
          }
        }
      }

      //滚动中需要单独实现的业务逻辑函数
      if (program) {
        program()
      }
    })
  },

  /**
   * 根据滚动指定的DIV
   * @param callback
   */
  pageScrollDiv: function (callback) {
    //需要特殊处理的滚动区域，需要放在scroller元素区域内
    $('.scoll-area').on('scroll', function () {
      if (pm.isScroll) {
        let scrollTop = $(this).scrollTop()//滚动条位置
        let windowHeight = $('.scoll-area').height()//显示区域高度
        let scrollHeight = $(this)[0].scrollHeight//页面内容区域实际高度
        if (pm.isScroll && scrollTop + windowHeight >= scrollHeight - 100) {
          $('.more').html('加载中…')

          //防止二次加载
          pm.isScroll = false
          pm.pageNum++

          if (callback) {
            callback()
          }
        }
      }
    })
  },

  //外部微信图片处理
  dealImgImportant: function (className, height) {
    $('.' + className + ' img').css('cssText', $('.' + className + ' img').attr('style') + ';height: ' + height + 'rem !important;')
  },

  //分享弹窗
  shareWindow: function (item) {
    let shareDiv = document.createElement('div')
    $(shareDiv).css({
      'width': '7.5rem',
      'height': '100%',
      'background-color': '#000000',
      'position': 'fixed',
      'top': '0px',
      'left': '0px',
      'opacity': '0.35',
      'z-index': '10003',
      'border': 'none',

    }).addClass('show-share').click(function () {
      $('.share-wrap').remove()
      $('.show-share').remove()
    })

    let shareList = [
      {
        name: '微信',
        img: 'iconweixin',
        scene: '0'/*微信好友*/
      },
      {
        name: '朋友圈',
        img: 'iconpengyouquan',
        scene: '1'/*朋友圈*/
      }
      // ,
      // {
      //   name: '新浪微博',
      //   img: 'iconweibo',
      //   scene: '3'
      // },
      // {
      //   name: "QQ",
      //   img: "iconQQ",
      //   scene: "4"
      // }
    ]
    window.choiseShareChannel = function (scene) {
      $('.share-wrap').remove()
      $('.show-share').remove()

      $.each(shareList, function (i, obj) {
        //设置分享方式
        if (scene === parseInt(obj.scene)) {
          item.scene = obj.scene
        }
      })
      Utils.goShare(item)
    }

    let htmlStr =
      '<div class="bg-white share-wrap">\n' +
      '            <div class="flex-row share-box flex-row justify-content-between">\n'

    $.each(shareList, function (i, obj) {
      htmlStr +=
        '                    <div class="flex-column share-item mt15" onclick=\'choiseShareChannel(' + obj.scene + ')\'>' +
        '                    <div class="share-icon flex-row justify-content-center align-items-center"><svg class="icon" aria-hidden="true">' +
        '                        <use xlink:href="#' + obj.img + '">' +
        '                    </svg></div>' +
        '                    <div class=\'fs13 c-5d\'>' + obj.name + '</div>' +
        '                </div>\n'
    })

    htmlStr +=
      '            </div>\n' +
      '            <div class="flex-row share-btn bg-white fs16">取消</div>\n' +
      '        </div>'

    $('body').append(shareDiv).append(htmlStr)

    //取消按钮
    $('.share-btn').click(function () {
      $('.share-wrap').remove()
      $('.show-share').remove()
    })
  },

  share: function () {

    let shareList = [
      {
        name: '微信',
        img: 'iconweixin',
        scene: '0'/*微信好友*/
      },
      {
        name: '朋友圈',
        img: 'iconpengyouquan',
        scene: '1'/*朋友圈*/
      }
      // ,
      // {
      //   name: '新浪微博',
      //   img: 'iconweibo',
      //   scene: '3'
      // },
      // {
      //   name: "QQ",
      //   img: "iconQQ",
      //   scene: "4"
      // }
    ]
    let htmlStr = '<div class=\'flex-row justify-content-center mt44\'>'
    htmlStr += '<div class=\'flex-row align-items-center\'>'
    htmlStr += '<div class=\'share-line\'></div>'
    htmlStr += '<div class=\'fs13 mr10 ml10 \'>分享到</div>'
    htmlStr += '<div class=\'share-line\'></div>'
    htmlStr += '</div>'
    htmlStr += '</div>'
    htmlStr += '<div class=\'flex-row justify-content-center mt18\'>'
    htmlStr += '<div class=\'flex-row align-items-center fs26\'>'

    $.each(shareList, function (i, obj) {
      htmlStr += '<div class=\'detail-share-item\' onclick="shareClick(\'' + obj.scene + '\')">'
      htmlStr += '<svg class=\'icon\' aria-hidden=\'true\'>'
      htmlStr += '<use xlink:href=\'#' + obj.img + '\'/>'
      htmlStr += '</svg>'
      htmlStr += '</div>'
    })

    htmlStr += '</div>'
    htmlStr += '</div>'
    return htmlStr
  },


  //图片放大弹窗
  imageWindow: function (imgUrl) {
    let imageDiv = document.createElement('div')
    $(imageDiv).css({
      'width': '7.5rem',
      'height': '100%',
      'background-color': '#000000',
      'position': 'fixed',
      'top': '0',
      'bottom': '0',
      'left': '0',
      'z-index': '10000',
      'border': 'none'
    }).addClass('show-image').click(function () {
      $('.image-wrap').remove()
      $('.show-image').remove()
    })

    let htmlStr =
      '<div class="image-wrap flex-1">\n' +
      '      <div class="img-back">\n' +
      '        <span class="iconfont iconfanhui left-bar c-white" style="margin-left:0.3rem;"></span>' +
      '      </div>' +
      '      <div class="img-region" style=\'height: 10rem\'>\n' +
      '        <div class=\'flex-column justify-content-center\' id=\'imgBox\' style=\'min-height: 10rem\'>\n' +
      '          <img src="' + imgUrl + '">' +
      '        </div>' +
      '      </div>\n' +
      '      <div class="img-back"></div>\n' +
      '</div>'

    $('body').append(imageDiv).append(htmlStr)
    let hei = window.screen.height - 128
    $('.img-region').css({
      height: hei + 'px'
    })
    $('#imgBox').css({
      minHeight: hei + 'px'
    })

    $('.img-back').click(function () {
      $('.image-wrap').remove()
      $('.show-image').remove()
    })

    this.touchScale()

  },

  //手指触碰图片放大缩小
  touchScale: function () {
    let startX, endX, scale, x1, x2, y1, y2, imgLeft, imgTop, imgWidth, imgHeight,
      one = false,
      $touch = $('.image-wrap img'),  //选择放大缩小的元素
      originalWidth = $touch.width(),
      imgData = [],
      bgTop = parseInt($('.image-wrap img').css('top'))

    function siteData(name) {
      imgLeft = parseInt(name.css('left'))
      imgTop = parseInt(name.css('top'))
      imgWidth = name.width()
      imgHeight = name.height()
    }

    $(document).on('touchstart touchmove touchend', $('.image-wrap img'), function (event) {

      let $me = $('.image-wrap img')

      touch1 = event.originalEvent.targetTouches[0],  // 第一根手指touch事件

      touch2 = event.originalEvent.targetTouches[1],  // 第二根手指touch事件

      fingers = event.originalEvent.touches.length   // 屏幕上手指数量

      //手指放到屏幕上的时候，还没有进行其他操作
      if (event.type === 'touchstart') {
        if (fingers === 2) {
          // 缩放图片的时候X坐标起始值
          startX = Math.abs(touch1.pageX - touch2.pageX)
          one = false
        } else if (fingers === 1) {//单指操作
          /*x1 = touch1.pageX;
                                        y1 = touch1.pageY;
                                        one = true;*/
        }
        //siteData($me);
      }
      //手指在屏幕上滑动
      else if (event.type === 'touchmove') {
        if (fingers === 2) {
          // 缩放图片的时候X坐标滑动变化值
          endX = Math.abs(touch1.pageX - touch2.pageX)
          scale = endX - startX

          $me.css({
            'width': originalWidth + scale,
            'height': originalWidth + scale
          })

        } else if (fingers === 1) {
          x2 = touch1.pageX
          y2 = touch1.pageY
        }
      }
      //手指移开屏幕
      else if (event.type === 'touchend') {
        // 手指移开后保存图片的宽
        originalWidth = $touch.width(),
        siteData($me)
        imgData = [[imgLeft, imgTop - bgTop, imgWidth, imgHeight], [0, 0, 640, 640]]
      }
    })
    let getData = function () {
      return imgData
    }
    return {
      imgData: getData
    }
  },


  /**
   * 倒计时处理
   * @param hid 热点数据
   * @param id 倒计时信息ID
   * @param flag 是否刷新按钮 true：刷新；false：不刷新
   * @returns
   */
  countTime: function (item, id, formart) {
    //获取当前时间
    let date = new Date()
    let now = date.getTime()
    //设置截止时间  ,直播结束时间
    let end = item.trainStartDttm * 1000

    //时间差
    let countDownTime = end - now
    //定义变量 d,h,m,s保存倒计时的时间
    let d = 0, h = 0, m = 0, s
    if (countDownTime >= 0) {
      d = Math.floor(countDownTime / 1000 / 60 / 60 / 24)
      h = Math.floor(countDownTime / 1000 / 60 / 60 % 24)
      m = Math.floor(countDownTime / 1000 / 60 % 60)
      s = Math.floor(countDownTime / 1000 % 60)

      h = h < 10 ? '0' + h : h
      m = m < 10 ? '0' + m : m
      s = s < 10 ? '0' + s : s

      let t = ''
      if (Utils.notEmpty(formart) && formart.indexOf('00:00') >= 0) {
        d = d < 10 ? '0' + d : d
        if (d > 0) {
          t += d + ' : ' + h + ' : ' + m + ' : ' + s
        } else {
          t += d + ' : ' + h + ' : ' + m + ' : ' + s
        }
      } else {
        if (d > 0) {
          t += d + '天' + h + '时' + m + '分' + s + '秒'
        } else {
          t += h + '时' + m + '分' + s + '秒'
        }
      }

      //将倒计时赋值到div中
      $('#' + id).html(t)

      clearTimeout(window[id])

      //递归每秒调用countTime方法，显示动态时间效果
      window[id] = setTimeout(function () {
        Template.countTime(item, id, formart)
      }, 1000)
    } else {
      //倒计时结束，开始直播
      if (item.trainingType === '1') {
        document.getElementById(id).innerHTML = '正在直播'
      } else {
        document.getElementById(id).innerHTML = item.trainStartDttmStr
      }
      $('.head-timedown').hide()
    }
  },
  /**
   * 系统公告
   * @param type(1、路闻 2、AI投研 3、DataGo 4、服务+ 5、头条)
   */
  noticeWindow: function (type) {
    let uri = 'information/infoSetUp/queryByPosition'
    Utils.http(uri, {
      position: '1'
    }).then(function success(data) {
      if (data._code === '0') {
        let noticeDiv = document.createElement('div')
        $(noticeDiv).css({
          'width': '7.5rem',
          'height': '100%',
          'background-color': '#000000',
          'position': 'fixed',
          'top': '0px',
          'left': '0px',
          'opacity': '0.35',
          'z-index': '10000',
          'border': 'none',

        }).addClass('show-notice').click(function () {
          $('.notice-wrap').remove()
          $('.show-notice').remove()
          $('.notice-close').remove()
          $('.notice-content').remove()
          $('.notice-tcp').remove()
          $('.notice-close-img').remove()
        })

        window.jumpUrl = function (url) {
          if (Utils.isEmpty(url)) {
            return
          } else {
            jsBridge.openWindow(url, {type: 2})
          }
        }
        window.noticeClose = function () {
          $('.notice-wrap').remove()
          $('.show-notice').remove()
          $('.notice-close').remove()
          $('.notice-content').remove()
          $('.notice-tcp').remove()
          $('.notice-close-img').remove()
        }
        let notice = data.notice
        let html = ''
        switch (parseInt(notice.noticeType)) {
        //图片
        case 1:
          html += '<div  class=\'notice-wrap\' onclick=\'jumpUrl(' + notice.urlType + ',' + notice.linkUrl + ')\'>'
          html += '<img class=\'notice-img\' src=\'' + notice.pictureUrl + '\'/>'
          html += '</div>'
          html += '<img onclick=\'noticeClose()\' class=\'notice-close\' src=\'../images/icon/notice_close.png\'>'
          break
          //内容
        case 2:
          html += '<div  class=\'notice-content\' onclick=\'jumpUrl(' + notice.urlType + ',' + notice.linkUrl + ')\'>'
          html += '<div class=\'content\'>'
          html += '<div class=\'content-content\'>' + Utils.dealUndefined(notice.introduction) + '</div>'
          html += '<div class=\'sure fs17 flex-row align-items-center justify-content-center\' onclick=\'noticeClose()\'>知道了</div>'
          html += '</div>'
          html += '</div>'
          break
          //标题+内容
        case 3:
          break
          //图片标题内容
        case 4:
          html += '<div  class=\'notice-tcp\' onclick=\'jumpUrl(' + notice.urlType + ',' + notice.linkUrl + ')\'>'
          html += '<img class=\'notice-tcp-con-img\' src=\'' + notice.pictureUrl + '\'/>'
          html += '<div class=\'notice-title flex-row align-items-center justify-content-center ff600 fs19 c-333\'>' + Utils.dealUndefined(notice.title) + '</div>'
          html += '<div class=\'content\'>' + Utils.dealUndefined(notice.introduction) + '</div>'
          html += '</div>'

          html += '<img onclick=\'noticeClose()\' class=\'notice-close-img\' src=\'../images/icon/notice_close.png\'>'
          break
        default:
          return
        }
        $('body').append(noticeDiv).append(html)
      }
    })

  },

  /**
   * 短信发送模板
   */
  sendCode: function (phone, codeId, timerId) {
    $('#' + codeId).val('')

    if (phone) {
      let wait_time = 60/*等待时间*/
      $('#' + codeId).text(wait_time).removeAttr('onclick')

      Utils.http('user/appUser/getVerificationCode', {
        phoneNum: phone
      }).then(function () {
        jsBridge.callBridge('toast', {msg: '验证码发送成功'})
      }).catch(function (data) {
        alert(data._message)
      })

      clearInterval(timerId)
      timerId = setInterval(function () {
        wait_time -= 1
        if (wait_time > 0) {
          $('#' + codeId).text(wait_time)
        } else {
          $('#' + codeId).text('获取验证码').attr('onclick', 'getCode()')
        }
      }, 1000)

      return timerId
    } else {
      jsBridge.callBridge('toast', {msg: '请输入正确的手机号'})
    }
  },

  opacityBar: function () {
    //获取当前机型bar的高度
    let sbh = ((systemConfig && systemConfig.statusBarHeight ? systemConfig.statusBarHeight : 0.4) + 0.88) * 100 / 2
    let scrollTop = $(this).scrollTop()

    let opacity = 0
    if (scrollTop < 0) {
      opacity = 0
    } else if (scrollTop <= sbh) {
      opacity = scrollTop / sbh
    } else {
      opacity = 1
    }

    $('.bar-opacity').css({
      background: 'rgba(19,56,74,' + opacity + ')'
    })
  },
  reportList: function (item) {
    let jsonStr = JSON.stringify({
      infoId: item.infoId,
      infoType: item.infoType
    })
    let htmlStr = '<div class=\'flex-row index-report-list-item w-100-p\' onclick=\'goDetail(' + jsonStr + ')\'>'
    htmlStr += '<div style="width: 100%"><div class=\'flex-column justify-content-between w-100-p\'>'
    htmlStr += '<div class=\'index-report-list-title line2 ff500\'>'
    htmlStr += '<img class="mr5" src=\' https://zzb.jddglobal.com/customer/manager/download/zzb/png/2802aa07-7ebe-49d7-bee0-d871daa7b08f.png \'/>'
    htmlStr += '<span class=\'fs15\'>' + item.mainTitle + '</span>'
    htmlStr += '</div>'
    if (item.trailContent) {
      item.trailContent = item.trailContent.replace(/<[^>]*?>/g, '')
      if (item.trailContent) {
        if (item.trailContent.length > 20) {
          htmlStr += '<div class=\'fs13 index-report-list-tri\'>' + item.trailContent.substring(0, 40) + '...<span>查看详情</span></div>'
        } else {
          htmlStr += '<div class=\'fs13 index-report-list-tri\'>' + item.trailContent + '</div>'
        }
      }
    }

    htmlStr += '<div class=\'index-report-list-time flex-row justify-content-between fs12 \'>'
    htmlStr += '<div>' + DateUtils.formatDate(new Date(item.issuerDttm * 1000), 'yyyy-MM-dd') + '</div>'
    htmlStr += '<div><span class="readCnt_' + item.infoId + '">' + (item.readCnt ? item.readCnt : 0) + '</span>阅读 · '
    htmlStr += '<span class="commentCnt_' + item.infoId + '">' + (item.commentCnt ? item.commentCnt : 0) + '</span>点评'
    htmlStr += '</div></div>'
    htmlStr += '</div></div></div>'
    return htmlStr
  },

  bottomPop: function (title, content) {
    let bg = document.createElement('div')
    $(bg).css({
      'position': 'fixed',
      'bottom': '0',
      'width': '100%',
      'opacity': '0.2',
      'height': '100rem',
      'background-color': 'black',
      'z-index': '10000'
    }).addClass('pop-ups-bg').click(function () {
      $('.pop-ups-bg').hide()
      $('.pop-ups-pop').hide()
    })
    let bottomPop = document.createElement('div')
    $(bottomPop).css({
      'position': 'fixed',
      'bottom': '0',
      'height': '6.1rem',
      'width': ' 100%',
      'display': 'flex',
      'flex-direction': 'column',
      'background-color': 'white',
      'border-radius': '10px 10px 0 0',
      'z-index': '10005',
      'padding': '0.36rem'
    }).addClass('pop-ups-pop')
    $('.pop-ups-bg').addClass('mescroll-touch')
    let html = ''
    html += '<div class=\'flex-row justify-content-end c-222 \'><span class=\'fs17 iconfont iconguanbi\' onclick=\'bottomPopClose()\'></span></div>'
    html += '<div class=\'flex-1 scoll-y mescroll-touch-y\'>'
    html += '<div class=\'fs20 mt5 c-222 ta-left  \'>' + title + '</div>'
    html += '<div class=\'mescroll-touch-content mt15 fs16\' style=\'color:rgba(34,34,34,0.7);line-height:0.44rem; \'>' + content + '</div>'
    html += '</div>'
    window.bottomPopClose = function () {
      $('.pop-ups-bg').hide()
      $('.pop-ups-pop').hide()
    }
    $('body').append(bg)
    $(bottomPop).append(html)
    $('body').append(bottomPop)
  },
  commentDetail: function (commentCnt, thumbsupCnt, noComment, noThumb) {
    let htmlStr = '<div class=\'p224 flex-row align-items-center\'>'
    htmlStr += '<div class=\'comment fs13 flex-1\' onclick=\'writeComment()\'>说说你的看法</div>'

    //评论
    if (!noComment) {
      htmlStr += '<div class=\'flex-row justify-content-center align-items-center comment-no-icon ml10 \' onclick=\'goComment()\'>'
      htmlStr += '<span class=\'iconfont iconpinglun fs17\'></span>'
      htmlStr += '<span class=\'comment-cnt fs12\'>' + (commentCnt ? commentCnt : '') + '</span>'
      htmlStr += '</div>'
    }
    //点赞
    if (!noThumb) {
      htmlStr += '<div class=\'flex-row comment-thumbsup\' onclick=\'goThumb()\'>'
      htmlStr += '<span class=\'comment-thumbsup-icon iconfont icondianzan fs18\'></span>'
      htmlStr += '<span class=\'comment-thumbsup-cnt fs12\'>' + (thumbsupCnt ? thumbsupCnt : '') + '</span>'
      htmlStr += '</div>'
    }
    htmlStr += '</div>'

    htmlStr += '<div class=\'comment-show comment-window\' onclick=\'showInput(0)\'></div>'
    htmlStr += '<div class=\'comment-window-out comment-show\' style=\'display: none\'>'
    htmlStr += '<div class=\'window-head\'>'
    htmlStr += '<div class="c-999" onclick=\'showInput(0)\'>取消</div>'
    htmlStr += '<div class="comment-send-btn" onclick=\'showInput(1)\'>发送</div>'
    htmlStr += ' </div>'
    htmlStr += '<div class=\'window-content\'>'
    htmlStr += '<textarea placeholder=\'发表你的看法\' class=\'comment-content fs15\' rows=\'2\' maxlength="300"></textarea>'
    htmlStr += '</div>'
    htmlStr += '</div>'
    return htmlStr
  },

  // 评论删除
  commentDel: function (item) {
    window.cancleDel = function () {
      $('.comment-del-bg').hide()
      $('.comment-del-option').hide()
    }
    let htmlStr = ''
    htmlStr += '<div class=\'comment-del-bg\'></div>'
    htmlStr += '<div class=\'comment-del-option\'>'
    htmlStr += '<div class=\'comment-del-del\' onclick=\'delComment(' + JSON.stringify({commentId: item.commentId}) + ')\'>删除</div>'
    htmlStr += '<div class=\'comment-del-cnacle\' onclick=\'cancleDel()\'>取消</div>'
    htmlStr += '</div>'
    $('.comment-del-area').html(htmlStr)
  },
  promptTip: function (val, o) {
    $('.prompt-tip-triangle').html(val)
    $('.prompt-tip-wrap').show()
    $('.prompt-tip-triangle').show()
    $('.prompt-tip-triangle').css('top', $(o).offset().top + 25)
    $('.prompt-tip-triangle').append(`<style>.prompt-tip-triangle::before{left:${$(o).offset().left - 30}px}</style>`)
    $('.prompt-tip-triangle').append(`<style>.prompt-tip-triangle::after{left:${$(o).offset().left - 30}px}</style>`)
    $('.prompt-tip-wrap').click(function () {
      $('.prompt-tip-wrap').hide()
      $('.prompt-tip-triangle').hide()
    })
  },
  createMeScroll: function (data) {
    let loadingImg = '<div class="app-loading flex-row justify-content-center"><img src="' + (data.loadImg ? data.loadImg : '../../images/loading.gif') + '"><div></div></div>'
    // let loadingImg = '<div class="app-loading flex-row justify-content-center"><span>正在加载</span><div></div></div>'
    //下拉刷新、滚动加载
    return new MeScroll(data.id, {
      down: {
        callback: data.downCallback, //下拉刷新的回调
        htmlContent: loadingImg,
      },
      up: {
        auto: false, //是否在初始化时以上拉加载的方式自动加载第一页数据; 默认false
        isBounce: false, //此处禁止ios回弹,解析(务必认真阅读,特别是最后一点): http://www.mescroll.com/qa.html#q10
        noMoreSize: data.noMoreSize ? data.noMoreSize : 10, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
        page: {
          num: data.pageNum ? data.pageNum : 0, //当前页 默认0,回调之前会加1; 即callback(page)会从1开始
          size: data.pageSize ? data.pageSize : 10 //每页数据条数,默认10
        },
        empty: {
          //列表第一页无任何数据时,显示的空提示布局; 需配置warpId才显示
          warpId: data.id, //父布局的id (1.3.5版本支持传入dom元素)
          icon: 'https://zzb.jddglobal.com/customer/manager/download/zzb/png/4ea87d78-95ef-4f1e-9b41-ac9de6d99a89.png',//'../../images/search/nodata3@3x.png', //图标,默认null,支持网络图
          tip: '暂无相关内容' //提示
        },
        callback: function (page) {
          data.upCallback(page)
        }, //上拉回调,此处可简写; 相当于 callback: function (page) { upCallback(page); }
        htmlNodata: '<div class="more">- 暂无更多数据 -</div>',
        lazyLoad: {
          use: true // 是否开启懒加载,默认false
        }
        //htmlLoading: loadingImg
      }
    })
  },
  createNoScroll: function (data) {
    let loadingImg = '<div class="app-loading flex-row justify-content-center"><img src="' + (data.loadImg ? data.loadImg : '../../images/loading.gif') + '"><div></div></div>'
    // let loadingImg = '<div class="app-loading flex-row justify-content-center"><span>正在加载</span><div></div></div>'
    //下拉刷新、滚动加载
    return new MeScroll(data.id, {
      down: {
        callback: data.downCallback, //下拉刷新的回调
        htmlContent: loadingImg,
      },
      up: {
        auto: false, //是否在初始化时以上拉加载的方式自动加载第一页数据; 默认false
        isBounce: false, //此处禁止ios回弹,解析(务必认真阅读,特别是最后一点): http://www.mescroll.com/qa.html#q10
        noMoreSize: data.noMoreSize ? data.noMoreSize : 10, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
        page: {
          num: data.pageNum ? data.pageNum : 0, //当前页 默认0,回调之前会加1; 即callback(page)会从1开始
          size: data.pageSize ? data.pageSize : 10 //每页数据条数,默认10
        },
        clearEmptyId: (data.clearEmptyId ? data.clearEmptyId : ''), //相当于同时设置了clearId和empty.warpId; 简化写法;默认null; 注意vue中不能配置此项
        empty: {
          //列表第一页无任何数据时,显示的空提示布局; 需配置warpId才显示
          warpId: data.id, //父布局的id (1.3.5版本支持传入dom元素)
          icon: 'https://zzb.jddglobal.com/customer/manager/download/zzb/png/4ea87d78-95ef-4f1e-9b41-ac9de6d99a89.png',//'../../images/search/nodata3@3x.png', //图标,默认null,支持网络图
          tip: '暂无相关内容' //提示
        },
        callback: '', //上拉回调,此处可简写; 相当于 callback: function (page) { upCallback(page); }
        htmlNodata: '<div class="more">- 暂无更多数据 -</div>',
        lazyLoad: {
          use: true // 是否开启懒加载,默认false
        }
        //htmlLoading: loadingImg
      }
    })
  },
  /**
   * 菜单水平移动
   * @param that 菜单对象
   * @param screenWid 频幕宽度
   * @param className 滚动区域的class名
   * @param activeClass 选中样式的class名
   */
  btnLevelMove: function (that, screenWid, className, activeClass) {
    if (!screenWid) {
      screenWid = 375
    }
    if (that) {
      //菜单左、右移 (321 / 375 * window.screen.width)
      let scrollLeft = that.offsetLeft - screenWid / 2 + $('.' + activeClass).outerWidth() / 2
      //清除元素的所有动画，让当前动画直接到达末状态
      $('.' + className).stop(true, true).animate({scrollLeft: scrollLeft})
    }
  },

  searchWordCache: function (obj) {
    //综合搜索，搜索词缓存
    jsBridge.getData('compSearchData').then(list => {
      let data = Utils.notEmpty(list) && Utils.notEmpty(list) ? list : []

      //最新的搜索放在第一个
      let currList = [], k = 0
      currList.push(obj)

      //最多放置9个历史数据
      $.each(data, function (i, item) {
        if (k < 9 && obj !== item) {
          currList.push(item)
          k++
        }
      })

      jsBridge.setData('compSearchData', currList)
    })
  },

  //搜索框页面样式
  searchArea: function (cls) {

    let htmlStr =
      `<div class="flex-row justify-content-between align-items-center index-search-box">
            <div class="flex-row justify-content-between align-items-center index-search-search">
                <div class="flex-row align-items-center w-100-p">
                    <span class="iconfont iconsousuo-01 fs16 index-search-icon"></span>
                    <form action="" onsubmit="return false;" class="w-100-p">
                        <input class="w-100-p ml10 fs14" type="search" id="keyWord" placeholder="请输入您感兴趣的内容">
                    </form>
                </div>
                <span class="iconfont iconshanchu fs16 index-search-sc dis-n"></span>
            </div>
            <div class="index-search-cancle fs14 ff400" onclick="clickBack()">取消</div>
        </div>`
    $('.' + cls).html(htmlStr)

    document.getElementById('keyWord').focus()

    $('.index-search-sc').click(function () {
      pm.keyWord = ''
      $('#keyWord').val(pm.keyWord)
      $('.index-search-sc').hide()
    })

    document.oninput = function (event) {
      if ($('#keyWord').val()) {
        $('.index-search-sc').show()
      } else {
        $('.index-search-sc').hide()
      }
    }

    document.onkeydown = function (event) {
      if (event.keyCode === 13) {//回车键的键值为13
        let key = $('#keyWord').val()
        if (key && Utils.replaceAll(key, ' ', '')) {
          goSearch(key)//回车需执行的方法
        } else if (key) {
          $('#keyWord').val('')
        }
      }
    }
  }

}
